<template>
  <div class="organizer-management">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-content">
        <h1 class="page-title">组织者管理</h1>
        <p class="page-subtitle">管理系统中的组织者账户</p>
      </div>
      <div class="header-actions">
        <el-button type="primary" @click="showCreateDialog">
          <el-icon><Plus /></el-icon>
          添加组织者
        </el-button>
        <el-button @click="exportData">
          <el-icon><Download /></el-icon>
          导出数据
        </el-button>
      </div>
    </div>

    <!-- 统计卡片 -->
    <el-row :gutter="20" class="stats-row">
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.total }}</div>
              <div class="stats-label">总组织者</div>
            </div>
            <el-icon class="stats-icon"><User /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.active }}</div>
              <div class="stats-label">活跃组织者</div>
            </div>
            <el-icon class="stats-icon active"><UserFilled /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.pending }}</div>
              <div class="stats-label">待审核</div>
            </div>
            <el-icon class="stats-icon pending"><Clock /></el-icon>
          </div>
        </el-card>
      </el-col>
      
      <el-col :xs="12" :sm="6">
        <el-card class="stats-card" shadow="hover">
          <div class="stats-content">
            <div class="stats-info">
              <div class="stats-number">{{ stats.disabled }}</div>
              <div class="stats-label">已禁用</div>
            </div>
            <el-icon class="stats-icon disabled"><Lock /></el-icon>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 搜索和筛选 -->
    <el-card class="filter-card">
      <el-form :model="filters" inline class="filter-form">
        <el-form-item label="关键词">
          <el-input
            v-model="filters.keyword"
            placeholder="搜索用户名、姓名、组织"
            clearable
            style="width: 200px"
            @keyup.enter="loadData"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
          </el-input>
        </el-form-item>
        
        <el-form-item label="状态">
          <el-select v-model="filters.status" placeholder="选择状态" clearable style="width: 120px">
            <el-option label="全部" value="" />
            <el-option label="活跃" value="active" />
            <el-option label="待审核" value="pending" />
            <el-option label="已禁用" value="disabled" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="注册时间">
          <el-date-picker
            v-model="filters.dateRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
            style="width: 240px"
          />
        </el-form-item>
        
        <el-form-item>
          <el-button type="primary" @click="loadData">
            <el-icon><Search /></el-icon>
            搜索
          </el-button>
          <el-button @click="resetFilters">
            <el-icon><Refresh /></el-icon>
            重置
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 组织者列表 -->
    <el-card class="table-card">
      <div v-if="loading" class="loading-container">
        <el-skeleton :rows="5" animated />
      </div>
      
      <div v-else>
        <el-table 
          :data="organizerList" 
          style="width: 100%"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          
          <el-table-column prop="avatar" label="头像" width="80">
            <template #default="{ row }">
              <el-avatar :size="40" :src="row.avatar">
                <el-icon><UserFilled /></el-icon>
              </el-avatar>
            </template>
          </el-table-column>
          
          <el-table-column prop="username" label="用户名" min-width="120" show-overflow-tooltip />
          
          <el-table-column prop="realName" label="真实姓名" min-width="100" show-overflow-tooltip />
          
          <el-table-column prop="organization" label="组织/部门" min-width="150" show-overflow-tooltip />
          
          <el-table-column prop="email" label="邮箱" min-width="180" show-overflow-tooltip />
          
          <el-table-column prop="phone" label="联系电话" width="130" />
          
          <el-table-column prop="activityCount" label="活动数量" width="100" sortable>
            <template #default="{ row }">
              <el-tag size="small">{{ row.activityCount }}</el-tag>
            </template>
          </el-table-column>
          
          <el-table-column prop="status" label="状态" width="100">
            <template #default="{ row }">
              <el-tag :type="getStatusType(row.status)" size="small">
                {{ getStatusText(row.status) }}
              </el-tag>
            </template>
          </el-table-column>
          
          <el-table-column prop="createdAt" label="注册时间" width="150">
            <template #default="{ row }">
              {{ formatDate(row.createdAt, 'YYYY-MM-DD') }}
            </template>
          </el-table-column>
          
          <el-table-column prop="lastLoginAt" label="最后登录" width="150">
            <template #default="{ row }">
              {{ row.lastLoginAt ? formatDate(row.lastLoginAt, 'MM-DD HH:mm') : '从未登录' }}
            </template>
          </el-table-column>
          
          <el-table-column label="操作" width="200" fixed="right">
            <template #default="{ row }">
              <el-button type="primary" size="small" text @click="viewDetail(row)">
                查看
              </el-button>
              <el-button type="warning" size="small" text @click="editOrganizer(row)">
                编辑
              </el-button>
              <el-dropdown @command="(command) => handleAction(command, row)">
                <el-button type="info" size="small" text>
                  更多<el-icon class="el-icon--right"><ArrowDown /></el-icon>
                </el-button>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item v-if="row.status === 'pending'" command="approve">
                      <el-icon><Check /></el-icon>
                      审核通过
                    </el-dropdown-item>
                    <el-dropdown-item v-if="row.status === 'active'" command="disable">
                      <el-icon><Lock /></el-icon>
                      禁用账户
                    </el-dropdown-item>
                    <el-dropdown-item v-if="row.status === 'disabled'" command="enable">
                      <el-icon><Unlock /></el-icon>
                      启用账户
                    </el-dropdown-item>
                    <el-dropdown-item command="resetPassword">
                      <el-icon><Key /></el-icon>
                      重置密码
                    </el-dropdown-item>
                    <el-dropdown-item command="delete" divided>
                      <el-icon><Delete /></el-icon>
                      删除账户
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </template>
          </el-table-column>
        </el-table>
        
        <!-- 批量操作 -->
        <div v-if="selectedOrganizers.length > 0" class="batch-actions">
          <span class="batch-info">已选择 {{ selectedOrganizers.length }} 个组织者</span>
          <el-button type="success" size="small" @click="batchApprove">
            <el-icon><Check /></el-icon>
            批量审核通过
          </el-button>
          <el-button type="warning" size="small" @click="batchDisable">
            <el-icon><Lock /></el-icon>
            批量禁用
          </el-button>
          <el-button type="danger" size="small" @click="batchDelete">
            <el-icon><Delete /></el-icon>
            批量删除
          </el-button>
        </div>
        
        <!-- 分页 -->
        <div v-if="organizerList.length > 0" class="pagination-container">
          <el-pagination
            v-model:current-page="pagination.current"
            v-model:page-size="pagination.size"
            :total="pagination.total"
            :page-sizes="[10, 20, 50, 100]"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="loadData"
            @current-change="loadData"
          />
        </div>
      </div>
    </el-card>

    <!-- 创建/编辑组织者对话框 -->
    <el-dialog
      v-model="dialogVisible"
      :title="dialogMode === 'create' ? '添加组织者' : '编辑组织者'"
      width="600px"
      @close="resetForm"
    >
      <el-form
        ref="formRef"
        :model="form"
        :rules="formRules"
        label-width="100px"
      >
        <el-form-item label="用户名" prop="username">
          <el-input 
            v-model="form.username" 
            placeholder="请输入用户名"
            :disabled="dialogMode === 'edit'"
          />
        </el-form-item>
        
        <el-form-item v-if="dialogMode === 'create'" label="密码" prop="password">
          <el-input 
            v-model="form.password" 
            type="password" 
            placeholder="请输入密码"
            show-password
          />
        </el-form-item>
        
        <el-form-item label="真实姓名" prop="realName">
          <el-input v-model="form.realName" placeholder="请输入真实姓名" />
        </el-form-item>
        
        <el-form-item label="组织/部门" prop="organization">
          <el-input v-model="form.organization" placeholder="请输入组织或部门名称" />
        </el-form-item>
        
        <el-form-item label="邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱地址" />
        </el-form-item>
        
        <el-form-item label="联系电话" prop="phone">
          <el-input v-model="form.phone" placeholder="请输入联系电话" />
        </el-form-item>
        
        <el-form-item label="状态" prop="status">
          <el-select v-model="form.status" placeholder="选择状态">
            <el-option label="活跃" value="active" />
            <el-option label="待审核" value="pending" />
            <el-option label="已禁用" value="disabled" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="备注">
          <el-input 
            v-model="form.remark" 
            type="textarea" 
            :rows="3"
            placeholder="请输入备注信息"
          />
        </el-form-item>
      </el-form>
      
      <template #footer>
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitForm" :loading="submitting">
          {{ dialogMode === 'create' ? '创建' : '保存' }}
        </el-button>
      </template>
    </el-dialog>

    <!-- 组织者详情对话框 -->
    <el-dialog
      v-model="detailDialogVisible"
      title="组织者详情"
      width="800px"
    >
      <div v-if="currentOrganizer" class="organizer-detail">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="头像">
            <el-avatar :size="60" :src="currentOrganizer.avatar">
              <el-icon><UserFilled /></el-icon>
            </el-avatar>
          </el-descriptions-item>
          <el-descriptions-item label="状态">
            <el-tag :type="getStatusType(currentOrganizer.status)">
              {{ getStatusText(currentOrganizer.status) }}
            </el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="用户名">{{ currentOrganizer.username }}</el-descriptions-item>
          <el-descriptions-item label="真实姓名">{{ currentOrganizer.realName }}</el-descriptions-item>
          <el-descriptions-item label="组织/部门">{{ currentOrganizer.organization }}</el-descriptions-item>
          <el-descriptions-item label="邮箱">{{ currentOrganizer.email }}</el-descriptions-item>
          <el-descriptions-item label="联系电话">{{ currentOrganizer.phone }}</el-descriptions-item>
          <el-descriptions-item label="活动数量">{{ currentOrganizer.activityCount }}</el-descriptions-item>
          <el-descriptions-item label="注册时间">
            {{ formatDate(currentOrganizer.createdAt, 'YYYY-MM-DD HH:mm:ss') }}
          </el-descriptions-item>
          <el-descriptions-item label="最后登录">
            {{ currentOrganizer.lastLoginAt ? formatDate(currentOrganizer.lastLoginAt, 'YYYY-MM-DD HH:mm:ss') : '从未登录' }}
          </el-descriptions-item>
          <el-descriptions-item label="备注" :span="2">
            {{ currentOrganizer.remark || '无' }}
          </el-descriptions-item>
        </el-descriptions>
        
        <!-- 最近活动 -->
        <div class="recent-activities">
          <h4>最近创建的活动</h4>
          <el-table :data="currentOrganizer.recentActivities" size="small">
            <el-table-column prop="title" label="活动名称" show-overflow-tooltip />
            <el-table-column prop="type" label="类型" width="100">
              <template #default="{ row }">
                <el-tag size="small">{{ getActivityTypeText(row.type) }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="status" label="状态" width="100">
              <template #default="{ row }">
                <el-tag :type="getActivityStatusType(row.status)" size="small">
                  {{ getActivityStatusText(row.status) }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="createdAt" label="创建时间" width="150">
              <template #default="{ row }">
                {{ formatDate(row.createdAt, 'MM-DD HH:mm') }}
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { formatDate } from '@/utils'
import { ElMessage, ElMessageBox } from 'element-plus'
import api from '@/utils/api'
import {
  Plus,
  Download,
  User,
  UserFilled,
  Clock,
  Lock,
  Unlock,
  Search,
  Refresh,
  ArrowDown,
  Check,
  Key,
  Delete
} from '@element-plus/icons-vue'

const loading = ref(false)
const dialogVisible = ref(false)
const detailDialogVisible = ref(false)
const dialogMode = ref('create')
const submitting = ref(false)
const formRef = ref()

const stats = reactive({
  total: 0,
  active: 0,
  pending: 0,
  disabled: 0
})

const filters = reactive({
  keyword: '',
  status: '',
  dateRange: null
})

const pagination = reactive({
  current: 1,
  size: 20,
  total: 0
})

const organizerList = ref([])
const selectedOrganizers = ref([])
const currentOrganizer = ref(null)

const form = reactive({
  id: null,
  username: '',
  password: '',
  realName: '',
  organization: '',
  email: '',
  phone: '',
  status: 'active',
  remark: ''
})

const formRules = {
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' },
    { min: 3, max: 20, message: '用户名长度在 3 到 20 个字符', trigger: 'blur' }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'blur' },
    { min: 6, max: 20, message: '密码长度在 6 到 20 个字符', trigger: 'blur' }
  ],
  realName: [
    { required: true, message: '请输入真实姓名', trigger: 'blur' }
  ],
  organization: [
    { required: true, message: '请输入组织或部门名称', trigger: 'blur' }
  ],
  email: [
    { required: true, message: '请输入邮箱地址', trigger: 'blur' },
    { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
  ],
  phone: [
    { required: true, message: '请输入联系电话', trigger: 'blur' },
    { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
  ],
  status: [
    { required: true, message: '请选择状态', trigger: 'change' }
  ]
}

const getStatusType = (status) => {
  const typeMap = {
    active: 'success',
    pending: 'warning',
    disabled: 'danger'
  }
  return typeMap[status] || ''
}

const getStatusText = (status) => {
  const textMap = {
    active: '活跃',
    pending: '待审核',
    disabled: '已禁用'
  }
  return textMap[status] || status
}

const getActivityTypeText = (type) => {
  const textMap = {
    lecture: '学术讲座',
    sports: '文体活动',
    club: '社团活动',
    volunteer: '志愿服务',
    practice: '实践活动',
    other: '其他'
  }
  return textMap[type] || type
}

const getActivityStatusType = (status) => {
  const typeMap = {
    draft: 'info',
    published: 'success',
    ongoing: 'warning',
    ended: '',
    cancelled: 'danger'
  }
  return typeMap[status] || ''
}

const getActivityStatusText = (status) => {
  const textMap = {
    draft: '草稿',
    published: '已发布',
    ongoing: '进行中',
    ended: '已结束',
    cancelled: '已取消'
  }
  return textMap[status] || status
}

const loadStats = async () => {
  try {
    const response = await api.get('/admin/organizers/stats')
    const data = response.data.data
    
    Object.assign(stats, data)
    
  } catch (error) {
    console.error('加载统计数据失败:', error)
  }
}

const loadData = async () => {
  try {
    loading.value = true
    
    const params = {
      page: pagination.current - 1,
      size: pagination.size,
      keyword: filters.keyword,
      status: filters.status
    }
    
    if (filters.dateRange && filters.dateRange.length === 2) {
      params.startDate = filters.dateRange[0]
      params.endDate = filters.dateRange[1]
    }
    
    const response = await api.get('/admin/organizers', { params })
    const data = response.data.data
    
    organizerList.value = data.data || []
    pagination.total = data.total || 0
    
  } catch (error) {
    console.error('加载组织者列表失败:', error)
    ElMessage.error('加载数据失败')
  } finally {
    loading.value = false
  }
}

const resetFilters = () => {
  Object.assign(filters, {
    keyword: '',
    status: '',
    dateRange: null
  })
  pagination.current = 1
  loadData()
}

const handleSelectionChange = (selection) => {
  selectedOrganizers.value = selection
}

const showCreateDialog = () => {
  dialogMode.value = 'create'
  resetForm()
  dialogVisible.value = true
}

const editOrganizer = (organizer) => {
  dialogMode.value = 'edit'
  Object.assign(form, {
    id: organizer.id,
    username: organizer.username,
    password: '',
    realName: organizer.realName,
    organization: organizer.organization,
    email: organizer.email,
    phone: organizer.phone,
    status: organizer.status,
    remark: organizer.remark || ''
  })
  dialogVisible.value = true
}

const resetForm = () => {
  Object.assign(form, {
    id: null,
    username: '',
    password: '',
    realName: '',
    organization: '',
    email: '',
    phone: '',
    status: 'active',
    remark: ''
  })
  if (formRef.value) {
    formRef.value.resetFields()
  }
}

const submitForm = async () => {
  try {
    await formRef.value.validate()
    
    submitting.value = true
    
    if (dialogMode.value === 'create') {
      await api.post('/admin/organizers', form)
      ElMessage.success('组织者创建成功')
    } else {
      await api.put(`/admin/organizers/${form.id}`, form)
      ElMessage.success('组织者更新成功')
    }
    
    dialogVisible.value = false
    loadData()
    loadStats()
    
  } catch (error) {
    if (error.response?.data?.message) {
      ElMessage.error(error.response.data.message)
    } else {
      ElMessage.error('操作失败')
    }
  } finally {
    submitting.value = false
  }
}

const viewDetail = async (organizer) => {
  try {
    const response = await api.get(`/admin/organizers/${organizer.id}`)
    currentOrganizer.value = response.data.data
    detailDialogVisible.value = true
    
  } catch (error) {
    console.error('加载组织者详情失败:', error)
    ElMessage.error('加载详情失败')
  }
}

const handleAction = async (command, organizer) => {
  switch (command) {
    case 'approve':
      await approveOrganizer(organizer)
      break
    case 'disable':
      await disableOrganizer(organizer)
      break
    case 'enable':
      await enableOrganizer(organizer)
      break
    case 'resetPassword':
      await resetPassword(organizer)
      break
    case 'delete':
      await deleteOrganizer(organizer)
      break
  }
}

const approveOrganizer = async (organizer) => {
  try {
    await ElMessageBox.confirm(
      `确定要审核通过组织者 "${organizer.realName}" 吗？`,
      '确认审核',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    await api.put(`/admin/organizers/${organizer.id}/approve`)
    ElMessage.success('审核通过成功')
    loadData()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const disableOrganizer = async (organizer) => {
  try {
    await ElMessageBox.confirm(
      `确定要禁用组织者 "${organizer.realName}" 吗？`,
      '确认禁用',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    await api.put(`/admin/organizers/${organizer.id}/disable`)
    ElMessage.success('禁用成功')
    loadData()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const enableOrganizer = async (organizer) => {
  try {
    await api.put(`/admin/organizers/${organizer.id}/enable`)
    ElMessage.success('启用成功')
    loadData()
    loadStats()
    
  } catch (error) {
    ElMessage.error('操作失败')
  }
}

const resetPassword = async (organizer) => {
  try {
    await ElMessageBox.confirm(
      `确定要重置组织者 "${organizer.realName}" 的密码吗？\n重置后的密码将发送到其邮箱。`,
      '确认重置密码',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    await api.put(`/admin/organizers/${organizer.id}/reset-password`)
    ElMessage.success('密码重置成功，新密码已发送到邮箱')
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const deleteOrganizer = async (organizer) => {
  try {
    await ElMessageBox.confirm(
      `确定要删除组织者 "${organizer.realName}" 吗？\n此操作不可恢复！`,
      '确认删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error'
      }
    )
    
    await api.delete(`/admin/organizers/${organizer.id}`)
    ElMessage.success('删除成功')
    loadData()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const batchApprove = async () => {
  try {
    await ElMessageBox.confirm(
      `确定要批量审核通过选中的 ${selectedOrganizers.value.length} 个组织者吗？`,
      '确认批量审核',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    const ids = selectedOrganizers.value.map(item => item.id)
    await api.put('/admin/organizers/batch-approve', { ids })
    ElMessage.success('批量审核成功')
    loadData()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const batchDisable = async () => {
  try {
    await ElMessageBox.confirm(
      `确定要批量禁用选中的 ${selectedOrganizers.value.length} 个组织者吗？`,
      '确认批量禁用',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
    
    const ids = selectedOrganizers.value.map(item => item.id)
    await api.put('/admin/organizers/batch-disable', { ids })
    ElMessage.success('批量禁用成功')
    loadData()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const batchDelete = async () => {
  try {
    await ElMessageBox.confirm(
      `确定要批量删除选中的 ${selectedOrganizers.value.length} 个组织者吗？\n此操作不可恢复！`,
      '确认批量删除',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'error'
      }
    )
    
    const ids = selectedOrganizers.value.map(item => item.id)
    await api.delete('/admin/organizers/batch', { data: { ids } })
    ElMessage.success('批量删除成功')
    loadData()
    loadStats()
    
  } catch (error) {
    if (error !== 'cancel') {
      ElMessage.error('操作失败')
    }
  }
}

const exportData = () => {
  ElMessage.info('数据导出功能开发中...')
}

onMounted(() => {
  loadStats()
  loadData()
})
</script>

<style scoped>
.organizer-management {
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 24px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content {
  flex: 1;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: #303133;
  margin: 0 0 8px 0;
}

.page-subtitle {
  font-size: 14px;
  color: #606266;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 12px;
  margin-left: 20px;
}

.stats-row {
  margin-bottom: 24px;
}

.stats-card {
  cursor: pointer;
  transition: transform 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-2px);
}

.stats-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.stats-info {
  flex: 1;
}

.stats-number {
  font-size: 24px;
  font-weight: 700;
  color: #303133;
  margin-bottom: 4px;
}

.stats-label {
  font-size: 14px;
  color: #909399;
}

.stats-icon {
  font-size: 28px;
  opacity: 0.3;
  color: #409eff;
}

.stats-icon.active {
  color: #67c23a;
}

.stats-icon.pending {
  color: #e6a23c;
}

.stats-icon.disabled {
  color: #f56c6c;
}

.filter-card,
.table-card {
  margin-bottom: 20px;
}

.filter-form {
  margin-bottom: 0;
}

.loading-container {
  padding: 20px;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  border-top: 1px solid #e4e7ed;
  margin-top: 16px;
}

.batch-info {
  color: #606266;
  font-size: 14px;
  margin-right: auto;
}

.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e4e7ed;
}

.organizer-detail {
  max-height: 600px;
  overflow-y: auto;
}

.recent-activities {
  margin-top: 24px;
}

.recent-activities h4 {
  margin: 0 0 16px 0;
  color: #303133;
  font-size: 16px;
  font-weight: 600;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .header-actions {
    margin-left: 0;
    flex-direction: column;
  }
  
  .filter-form {
    flex-direction: column;
  }
  
  .filter-form .el-form-item {
    margin-right: 0;
    margin-bottom: 16px;
  }
  
  .batch-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .batch-info {
    margin-right: 0;
    margin-bottom: 12px;
    text-align: center;
  }
}
</style>